<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!--360浏览器优先以webkit内核解析-->
    <!--    <title>若依介绍</title>-->
    <link rel="shortcut icon" href="favicon.ico">
    <link href="../static/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" rel="stylesheet" />
    <link href="../static/css/font-awesome.min.css" th:href="@{/css/font-awesome.min.css}" rel="stylesheet" />
    <link href="../static/css/main/animate.min.css" th:href="@{/css/main/animate.min.css}" rel="stylesheet" />
    <link href="../static/css/main/style.min862f.css" th:href="@{/css/main/style.min862f.css}" rel="stylesheet" />
</head>

<body class="white-bg">

<div class="wrapper wrapper-content animated fadeInRight ibox-content" th:if="${customerService != null}">
    <h2>欢迎您，<span th:text="${customerService.name}"></span> <small>请记得打卡哦</small></h2>

    <div class="row">
        <div class="col-sm-6">
            <form class="form-horizontal m" id="form-task-add" th:if="${customerService.state.ordinal() eq 1}" method="POST" action="/bajiaostar/customer_service/working">
                <input id="id" name="id" th:field="${customerService.id}" type="hidden">
                <div class="form-group">
                    <label class="col-sm-2 control-label">班次：</label>
                    <div class="col-sm-8">
                        <select name="scheduleConfigId" class="form-control" required="required">
                            <option value="">请选择</option>
                            <option th:each="config:${configs}" th:value="${config.id}" th:text="${config.timeDesc + '-' + config.identity.name}"
                                    th:selected="${config.identity eq customerService.identity}">options
                            </option>
                        </select>
                    </div>
                </div>

                <div class="form-group" th:if="${customerService.isAuxiliary}">
                    <label class="col-sm-2 control-label">辅助对象：</label>
                    <div class="col-sm-8">
                        <select name="auxiliaryCustomerId" class="form-control" required>
                            <option value="">请选择</option>
                            <option th:each="customer:${customers}" th:value="${customer.id}" th:text="${customer.name}"
                                    th:selected="${customer.id eq customerService.auxiliaryCustomerId}">options
                            </option>
                        </select>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-8">
                        <button type="submit" class="btn btn-success">上班打卡</button>
                    </div>
                </div>
            </form>

            <form class="form-horizontal m" id="form-task-add" th:if="${customerService.state.ordinal() eq 0}" method="POST" action="/bajiaostar/customer_service/free">
                <input id="id" name="id" th:field="${customerService.id}" type="hidden">
                <div class="form-group">
                    <label class="col-sm-2 control-label">班次：</label>
                    <div class="col-sm-8 form-control-static">
                        <span th:text="${customerService.timeDesc + '-' + customerService.identity.name}"></span>
                    </div>
                </div>

                <div class="form-group" th:if="${customerService.isAuxiliary}">
                    <label class="col-sm-2 control-label">辅助对象 ：</label>
                    <div class="col-sm-8 form-control-static">
                        <span th:text="${customerService.auxiliaryCustomerName}"></span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label"></label>
                    <div class="col-sm-8">
                        <button type="submit" class="btn btn-danger">下班打卡</button>
                    </div>
                </div>
            </form>
        </div>
    </div>

</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "bajiaostar/customer_service"

    $("#form-task-add").validate({
        focusCleanup: true,
        submitHandler: function (form) {

            //eg1
            layer.confirm('您确定执行该操作?', {icon: 3, title: '提示'}, function (index) {
                var config = {
                    url: $(form).attr("action"),
                    type: "post",
                    dataType: "json",
                    data: $(form).serialize(),
                    beforeSend: function () {
                        $(form).find("button").attr("disabled", true);
                    },
                    success: function (result) {
                        layer.confirm(result.msg, {
                            btn: ['确定'] //可以无限个按钮
                            , btn1: function (index, layero) {
                                location.href = location.href;
                            }
                        });
                    },
                    complete: function () {
                        $(form).find("button").attr("disabled", false);
                    }
                };
                $.ajax(config)
            });

            return false;
        }
    });
</script>
</body>


<script th:src="@{/js/jquery.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>
<script th:src="@{/ajax/libs/layer/layer.min.js}"></script>

<script type="text/javascript">
    $('#pay-qrcode').click(function () {
        var html = $(this).html();
        parent.layer.open({
            title: false,
            type: 1,
            closeBtn: false,
            shadeClose: true,
            area: ['600px', 'auto'],
            content: html
        });
    });
</script>
</body>
</html>
